package from_0_to_50;

import java.util.Arrays;

public class Q07 {
    public static void main(String[] args) {
        int x = 1534236469;
        System.out.println("new Q07().reverse(x) = " + new Q07().reverse(x));
        int a = 1,b = 1;
        for (int i = 0; i < 31; i++) {
            a *= 2;
            b *= -2;
        }
        System.out.println("a = " + (a-1));
        System.out.println("b = " + b);
    }
    public int reverse(int x) {
        int stack[] = new int[20];
        int top = 0;
        long result = 0L;
        if(x == 0)
            return  0;
        while (x%10 == 0 ){
            x /= 10;
        }
        while (Math.abs(x) > 0){
            stack[top++] = x%10;
            x /= 10;
        }
        for (int i = 0; i < top; i++) {
            result += stack[i] * Math.pow(10, top-i-1);
        }
        if(result <-2147483648 || result > 2147483647)
            result = 0;
        return (int)result;
    }
}
